package com.yazi.mxz.job.controller;

import javax.annotation.Resource;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myframework.smhj.jackson.result.StatusResult;
import com.yazi.mxz.job.quartz.OrderReturnedJob;
import com.yazi.mxz.job.quartz.OrderSuccessJob;

@Controller("orderController")
@RequestMapping("/order")
public class OrderController {

	private static Logger log = LoggerFactory.getLogger(OrderController.class);

	@Resource
	OrderSuccessJob orderSuccessJob;
	@Resource
	OrderReturnedJob orderReturnedJob;

	@RequestMapping("/success")
	@ResponseBody
	public StatusResult success() {
		log.debug("远程请求订单自动确认收货");
		StatusResult jsonResult = new StatusResult();
		try {
			orderSuccessJob.checkDoit();
			jsonResult.setOkMessage("ok");
		} catch (Exception e) {
			log.warn("订单自动确认收货异常: ", e);
			jsonResult.setErrorMessage(e.getMessage());
		}
		return jsonResult;
	}
	
	@RequestMapping("/returned")
	@ResponseBody
	public StatusResult returned() {
		log.debug("远程请求订单自动确认退货");
		StatusResult jsonResult = new StatusResult();
		try {
			orderReturnedJob.checkDoit();
			jsonResult.setOkMessage("ok");
		} catch (Exception e) {
			log.warn("订单自动确认退货异常: ", e);
			jsonResult.setErrorMessage(e.getMessage());
		}
		return jsonResult;
	}

}
